var utils = {
	getUrlParameter : function(key) {
		return (document.location.search.match(new RegExp("(?:^\\?|&)" + key
				+ "=(.*?)(?=&|$)")) || ['', null])[1];
	},
    loadPage:function(page,referTo){
    	$('#'+referTo).load(page);
    },
    getProvince:function(id){
        $.ajax({
            type: "GET",
            url: config.baseURL + "util/province.json",
            cache:false,
            dataType: "json",
            success: function(data){
                if(data.result == "success"){
                	var html = "<option value='0'>选择省份</option>";
                	$.each(data.provinceList,function(index, obj){
                        if(id && obj.id == id){
            		        html += "<option value='"+obj.id+"' selected='selected' provinceId='"+obj.provinceId+"'>"+obj.province+"</option>";
                        }else{
                            html += "<option value='"+obj.id+"' provinceId='"+obj.provinceId+"'>"+obj.province+"</option>";
                        }
                	});
                	$('#province').html(html);
                }else{
                    alert('获取省份异常，请稍候再试！');
                }
            }
        });
    },
    getCity:function(provinceId,cityId){
    	if(provinceId!=0){
            $.ajax({
                type: "GET",
                url: config.baseURL + "util/city.json",
                cache:false,
                dataType: "json",
                data: {"provinceId":provinceId},
                success: function(data){
                    if(data.result == "success"){
                    	var html = "<option value='0'>选择城市</option>";
                    	$.each(data.cityList,function(index, obj){
                    		if(cityId && obj.id == cityId){
                                html += "<option value='"+obj.id+"' selected='selected' cityId='"+obj.cityId+"'>"+obj.city+"</option>";
                    		}else{
                                html += "<option value='"+obj.id+"' cityId='"+obj.cityId+"'>"+obj.city+"</option>";
                    		}
                    	});
                    	$('#city').html(html);
                    }else{
                        alert('获取城市异常，请稍候再试！');
                    }
                }
            });
    	}
    },
    getArea:function(cityId,areaId){
    	if(cityId!=0){
            $.ajax({
                type: "GET",
                url: config.baseURL + "util/area.json",
                cache:false,
                dataType: "json",
                data: {"cityId":cityId},
                success: function(data){
                    if(data.result == "success"){
                    	var html = "<option value='0'>选择地区</option>";
                    	$.each(data.areaList,function(index, obj){
                    		if(areaId && obj.id == areaId){
                                html += "<option value='"+obj.id+"' selected='selected'>"+obj.area+"</option>";
                    		}else{
                                html += "<option value='"+obj.id+"'>"+obj.area+"</option>";
                    		}
                    	});
                    	$('#area').html(html);
                    }else{
                        alert('获取地区异常，请稍候再试！');
                    }
                }
            });
    	}
    }
};